<template>
  <div>
    <van-tabbar
      v-model="active"
      active-color="#ff4b50"
      inactive-color="#929292"
    >
      <van-tabbar-item name="/index" to="/index">
        <span class="iconfont icon-shouye" slot="icon"></span>
        <span @click="Index">首页</span>
      </van-tabbar-item>
      <van-tabbar-item name="/list" to="/list">
        <span class="iconfont icon-fenlei" slot="icon"></span>
        <span>分类</span>
      </van-tabbar-item>
      <van-tabbar-item name="/car" to="/car">
        <span class="iconfont icon-gouwuche1" slot="icon"></span>
        <span>购物车</span>
      </van-tabbar-item>
      <van-tabbar-item name="/ucenter" to="/ucenter">
        <span class="iconfont icon-wode" slot="icon"></span>
        <span>我的</span>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import Vue from "vue";
import { Tabbar, TabbarItem } from "vant";

Vue.use(Tabbar);
Vue.use(TabbarItem);
export default {
  data() {
    return {
      active: this.changeFooter(),
    };
  },
  methods: {
    Index() {
      this.$router.push("/index");
    },
    changeFooter() {
      let path = window.location.pathname;
      if (path === "/") {
        path = "/index";
      }
      return path;
    },
  },
};
</script>

<style lang="scss" scoped>
.iconfont {
  font-size: 22px;
}
</style>
